# 1.打开浏览器
from time import sleep

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

service = Service(executable_path=r'E:\python\pythonshuju\chromedriver.exe')
driver = webdriver.Chrome(service=service)  #创建浏览器对象
# 2.输入访问地址（URL）
url = r"E:\pyCharm\PyCharm Pro 2024.1\PyCharmshuju\PycharmProjects\UI自动化测试\1\注册实例.html";
driver.get(url)


# 1). 填写主页面的注册信息
# 用户名
driver.find_element(By.CSS_SELECTOR,"#user").send_keys("admin")
# 密码
driver.find_element(By.CSS_SELECTOR,"#password").send_keys("123456")
# 电话号码
driver.find_element(By.CSS_SELECTOR,"#tel").send_keys("13012345678")
# 电子邮件
driver.find_element(By.CSS_SELECTOR,"#email").send_keys("123@qq.com")


# 切换到注册A
# 1. 完成主页面注册信息；  done
# 2. 调用frame切换方法(switch_to.frame("myframe1"))切换到注册用户A框架中
# driver.switch_to.frame("myframe1")  # 使用name切换
driver.switch_to.frame("idframe1")     # 使用id切换
# 2). 填写注册页面A中的注册信息
# 用户名
driver.find_element(By.CSS_SELECTOR,"#userA").send_keys("1111")
# # 密码
driver.find_element(By.CSS_SELECTOR,"#passwordA").send_keys("123456")
# 电话号码
driver.find_element(By.CSS_SELECTOR,"#telA").send_keys("13012345678")
# 电子邮件
driver.find_element(By.CSS_SELECTOR,"#emailA").send_keys("123@qq.com")



# 3. 调用恢复默认页面方法(switch_to.default_content())
driver.switch_to.default_content()
# 4. 调用frame切换方法(switch_to.frame("myframe2"))切换到注册用户B框架中
#切换到注册B页面 使用name
driver.switch_to.frame("myframe2")
# 2). 填写注册页面B中的注册信息
# 用户名
driver.find_element(By.CSS_SELECTOR,"#userB").send_keys("1111")
# # 密码
driver.find_element(By.CSS_SELECTOR,"#passwordB").send_keys("123456")
# 电话号码
driver.find_element(By.CSS_SELECTOR,"#telB").send_keys("13012345678")
# 电子邮件
driver.find_element(By.CSS_SELECTOR,"#emailB").send_keys("123@qq.com")




# 4.关闭/退出浏览器
driver.quit()